//
//  TeacherQueDetailVC.m
//  inquiry
//
//  Created by 高宇 on 2020/7/29.
//  Copyright © 2020 高宇. All rights reserved.
//

#import "TeacherQueDetailVC.h"
#import "ULNetHelper.h"
#import "Interface.h"
#import "NSString+MD5.h"

@interface TeacherQueDetailVC ()
@property (weak, nonatomic) IBOutlet UITextView *textView;

@end

@implementation TeacherQueDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(0, 0, 40, 30);
    [backButton setTitle:@" 返回" forState:UIControlStateNormal];
    [backButton setTitleColor:[UIColor colorWithRed:173/255.0 green:173/255.0 blue:189/255.0 alpha:1.0] forState:0];
    [backButton setImage:[[UIImage imageNamed:@"fanhui"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];

    [backButton addTarget:self action:@selector(backClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    [self getData];
}

//在页面出现的时候就将黑线隐藏起来
 -(void)viewWillAppear:(BOOL)animated
{
    //显示导航栏下面的线条
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = nil;
}

- (void)backClick:(id)sender {
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)getData{
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString *teacherId = [user objectForKey:@"teacherId"];
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    dic[@"questionnaireId"] = self.questionnaireId;
    dic[@"studentId"] = self.studentId;
    dic[@"teacherId"] = teacherId;
    
    [ULNetHelper POST:queryAnswerDetailFromPreviewPath parameters:dic success:^(id responseObject) {
        NSDictionary *dic = responseObject;
        long code = [dic[@"code"] longValue];
        if (code == 200) {
            self.textView.text = dic[@"data"];
        }else{
            NSLog(@"问卷请求失败");
        }
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
